# -*- coding: utf-8 -*-

"""
    http://projecteuler.net/problem=6
    
    The sum of the squares of the first ten natural numbers is,
        12 + 22 + ... + 102 = 385

    The square of the sum of the first ten natural numbers is,
        (1 + 2 + ... + 10)2 = 552 = 3025
    
    Hence the difference between the sum of the squares of the first ten
    natural numbers and the square of the sum is 3025 − 385 = 2640.

    Find the difference between the sum of the squares of the first one hundred
    natural numbers and the square of the sum.
"""
import time
import math



def timeit(f):
    def timer():
        t0 = time.time()
        returned = f()
        print "time %s: %.6f" % (f, time.time() - t0)
        return returned
    return timer


@timeit    
def test_case():
    expected = 2640
    limit = 10
    difference = square_sum_difference(limit)
    
    assert difference == expected, "difference %s != expected %s" % (
            difference, expected)
    print "test case succeeded! %d" % (difference)

    
@timeit
def solution():
    limit = 100
    return square_sum_difference(limit)


def square_sum_difference(n):
    return square_of_sum(n) - sum_of_squares(n)
    
    
def square_of_sum(n):
    sum_ = sum(range(1,n+1))
    return sum_**2


def sum_of_squares(n):
    return sum([i**2 for i in xrange(1,n+1)])



if __name__ == '__main__':
    test_case()
    print solution()
    